package com.eascs.spider.kuaixiao;

import java.util.HashMap;
import java.util.Map;

import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.eascs.spider.kuaixiao.manager.TaskManager;
import com.eascs.spider.kuaixiao.util.NetUtil;

/**
 * Hello world!
 *
 */
public class App {
	
    public static void main( String[] args ){
    	CloseableHttpClient client = NetUtil.initHttpClient();
        TaskManager manager = TaskManager.getInstance();
    	//1，以产品供应为起点
    	String productUrl = "http://product.11467.com/shipin/";
    	Map<String, String> header = new HashMap<>();
    	header.put("Referer", "http://product.11467.com");
    	header.put("Host", "product.11467.com");
    	String productHtml = NetUtil.loadPageRawTextByGet(productUrl, client, header, null);
    	Elements elements = Jsoup.parse(productHtml).select("div#il div.box a");
    	for(Element element : elements){
    		String url = "http:" + element.attr("href");
    		manager.addUrl(url);
    		break;
    	}
    	
    }
}
